package com.sjhang.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sjhang.entity.TbCodeing;
import com.sjhang.mapper.TbCodeingMapper;
import com.sjhang.service.TbCodeingService;
import com.sjhang.utils.ListParamVo;
import com.sjhang.utils.ResultResponse;
import com.sjhang.vo.CodeingVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 大纲教学代码
 服务实现类
 *
 */
@Service
public class TbCodeingServiceImpl extends ServiceImpl<TbCodeingMapper, TbCodeing> implements TbCodeingService {

    @Resource
    private TbCodeingMapper tbCodeingMapper;

    /***
     * @description 查询全部代码块
     */
    @Override
    public ResultResponse selectCodeIng(ListParamVo listParamVo) {
        IPage<CodeingVo> page = tbCodeingMapper.selectCodeIng(
                new Page<CodeingVo>(listParamVo.getCurrent(),listParamVo.getSize()),
                 listParamVo.getParamMap().get("teacherID"), listParamVo.getParamMap().get("teach")
        );
        return ResultResponse.SUCCESS(page);
    }


    /***
     * @description 新增代码块
     * @params [listParamVo]
     */
    @Override
    public ResultResponse insertCodeIng(TbCodeing listParamVo) {
        tbCodeingMapper.insert(listParamVo);
        return ResultResponse.SUCCESS();
    }

    /***
     * @description 修改代码快
     * @params [listParamVo]
     */
    @Override
    public ResultResponse updateCodeIng(TbCodeing listParamVo) {
        tbCodeingMapper.updateById(listParamVo);
        return ResultResponse.SUCCESS();
    }

    /***
     * @description 删除代码块
     * @params [listParamVo]
     */
    @Override
    public ResultResponse deleteCodeIng(Long listParamVo) {
        tbCodeingMapper.deleteById(listParamVo);
        return ResultResponse.SUCCESS();
    }
}
